package org.compiere.process;

import org.compiere.model.Mhrmvacationschedule;
import org.compiere.model.MhrmvacationscheduleLine;
import org.eevolution.model.X_HR_Employee;

public class ProcessVacationSchedule extends SvrProcess {

	/** Model for Vacation Schedule*/
	private Mhrmvacationschedule hrmVa = null;
	/***/
	private  X_HR_Employee[] hremp = null;
	
	@Override
	protected void prepare() {
		hrmVa = new Mhrmvacationschedule(getCtx(), getRecord_ID(), get_TrxName());
		hremp = hrmVa.getHR_EmployeeDepartment();	
	}

	@Override
	protected String doIt() throws Exception {
		
		for(X_HR_Employee h: hremp){
			MhrmvacationscheduleLine hrmVaLine = MhrmvacationscheduleLine.getVacationscheduleLine(h.getC_BPartner_ID(), hrmVa.gethrm_years_ID());
			hrmVaLine.sethrm_vacationschedule_ID(hrmVa.gethrm_vacationschedule_ID());
			hrmVaLine.setC_BPartner_ID(h.getC_BPartner_ID());
			hrmVaLine.saveEx();
		}
		
		//
		hrmVa.setProcessing(true);
		hrmVa.saveEx();
		
		return "Lines are added";
	}

}
